package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.VoteLog;

/**
 * 
 * @author 
 *
 */
@DAO
public interface VoteLogDAO{
	
	@SQL("SELECT * FROM voteLog WHERE 1=1 "
	    	    				    		        	+ " AND subjectId=:t.subjectId"
	        			    		        	+ " AND itemId=:t.itemId"
	        			    		        	+ " AND dvcOrIP=:t.dvcOrIP"
	        			    		        	+ " AND deleteFlag=:t.deleteFlag"
	        			    		        	+ " AND createUser=:t.createUser"
	        			    		        	+ " AND createAt=:t.createAt"
	        			    		        	+ " AND updateUser=:t.updateUser"
	        			    		        	+ " AND updateAt=:t.updateAt"
	        				+" ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<VoteLog> query(@SQLParam("t") VoteLog voteLog);
    
    @SQL("select * from voteLog where id=:1")
    VoteLog queryById(int id);
    
    @SQL("INSERT INTO voteLog ("
			        		+ "subjectId,"
			        		+ "itemId,"
			        		+ "dvcOrIP,"
			        		+ "deleteFlag,"
			        		+ "createUser,"
			        		+ "createAt,"
			        		+ "updateUser,"
			        		+ "updateAt"
							+") VALUES ("
							+ ":t.subjectId,"
							+ ":t.itemId,"
							+ ":t.dvcOrIP,"
							+ ":t.deleteFlag,"
							+ ":t.createUser,"
							+ ":t.createAt,"
							+ ":t.updateUser,"
							+ ":t.updateAt"
					+")")
    void create(@SQLParam("t") VoteLog voteLog);
	
	@SQL("UPDATE voteLog SET "
		    		    						    			        + "subjectId=:t.subjectId,"
		        					    			        + "itemId=:t.itemId,"
		        					    			        + "dvcOrIP=:t.dvcOrIP,"
		        					    			        + "deleteFlag=:t.deleteFlag,"
		        					    			        + "createUser=:t.createUser,"
		        					    			        + "createAt=:t.createAt,"
		        					    			        + "updateUser=:t.updateUser,"
		        					    			        + "updateAt=:t.updateAt,"
		        						+ " WHERE id=:t.id")
    void update(@SQLParam("t") VoteLog voteLog);
    
    @SQL("UPDATE voteLog SET deleteFlag=0 WHERE id=:id")
    void deleteById(int id);
}